 
#include <string.h>
#include <math.h>
#include "system.h"
#include "f1c100s_de.h"
#include "f1c100s_timer.h"
#include "f1c100s_intc.h"
#include "f1c100s_gpio.h"
#include "f1c100s_pwm.h"
#include "f1c100s_uart.h"
#include "arm32.h"
#include "time0.h"
#include "f1c100s_audio.h"
#include "f1c100s_dma.h"
#include "waveio.h"
extern unsigned char wavdata[403432];

int main(void)
{
  system_init();            // Initialize clocks, mmu, cache, uart, ...
  arm32_interrupt_enable(); // Enable interrupts
  timer0_init();
  printf("\r\napp [AUDIO] run. compiled_time %s %s\r\n", __DATE__, __TIME__);
  delay(200);
  f1c100s_audio_init();
  f1c100s_audio_config(0, 16, 48000);
  f1c100s_audio_open(19200 / 60);
  f1c100s_audio_vol_set(40);

  printf("short :%d\r\n", sizeof(short));

  printf("wave_head_size:%d", sizeof(waveHeader_t));

  waveHeader_t wavhead;
  memcpy(&wavhead, wavdata, sizeof(waveHeader_t));
  wavfile_info(&wavhead);

  while (1)
  {
    for (int i = 0; i < (sizeof(wavdata) / 32768); i++)
    {
      audio_pcm_play((unsigned char *)&wavdata[i * 32768 + 44], 32768);
    }
    delay(1000);
  }
}
